"""
@Time ： 2021/11/15 16:27
@Auth ： ChenZhangKun
"""
from time import sleep

from selenium import webdriver

from Selenium常用的关键字 import SeleniumSpec


def open_browser(txt):
    if txt == "chrome":
        webDriver = webdriver.Chrome(SeleniumSpec.chormPath)
    return webDriver


class Key:
    """
    工具类的封装
    """

    def __init__(self, txt):
        self.webDrier = open_browser(txt)

    def locator(self, name, value):
        return self.webDrier.find_element(name, value)

    def click(self, name, value):
        self.locator(name, value).click()

    def input(self, name, value, txt):
        self.locator(name, value).send_keys(txt)

    def open(self, txt):
        self.webDrier.get(txt)

    def quit(self):
        self.webDrier.quit()

    def sleep(self, txt):
        sleep(txt)

    def implict(self, txt):
        self.webDrier.implicitly_wait(txt)
